package com.h2.util.lang.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public final class ReflectUtils
{
  public static final String[] PREFIXES = { "get", "set", "is", "add", "has" };

  public static Integer countConstructors(Class<?> paramClass, Integer paramInteger)
  {
    int i = 0;
    Constructor[] arrayOfConstructor = paramClass.getConstructors();
    Integer localInteger = Integer.valueOf(0);
    int j = arrayOfConstructor.length;
    while (true)
    {
      if (i >= j)
        return localInteger;
      if (arrayOfConstructor[i].getParameterTypes().length == paramInteger.intValue())
        localInteger = Integer.valueOf(1 + localInteger.intValue());
      i++;
    }
  }

  public static <T> Constructor<T> getConstructor(Class<T> paramClass, Integer paramInteger)
  {
    Constructor[] arrayOfConstructor = paramClass.getConstructors();
    int i = arrayOfConstructor.length;
    for (int j = 0; ; j++)
    {
      Object localObject;
      if (j >= i)
        localObject = null;
      do
      {
        return localObject;
        localObject = arrayOfConstructor[j];
      }
      while (((Constructor)localObject).getParameterTypes().length == paramInteger.intValue());
    }
  }

  public static <T> Constructor<T> getConstructorIfAvailable(Class<T> paramClass, Class<?>[] paramArrayOfClass)
  {
    try
    {
      Constructor localConstructor = paramClass.getConstructor(paramArrayOfClass);
      return localConstructor;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
    }
    return null;
  }

  public static String getDenormalizedName(String paramString)
  {
    if (paramString == null)
      return null;
    return paramString.substring(0, 1).toUpperCase() + paramString.substring(1);
  }

  public static String getDenormalizedName(Method paramMethod)
  {
    if (paramMethod == null)
      return null;
    return getDenormalizedName(paramMethod.getName());
  }

  public static Method getGetterMethod(Method paramMethod)
  {
    String str = getNormalizedName(paramMethod);
    Class localClass = paramMethod.getDeclaringClass();
    try
    {
      Method localMethod = localClass.getMethod("get" + getDenormalizedName(str), new Class[0]);
      return localMethod;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      return null;
    }
    catch (SecurityException localSecurityException)
    {
    }
    return null;
  }

  public static String getNormalizedName(String paramString)
  {
    String str1 = paramString;
    String[] arrayOfString = PREFIXES;
    int i = arrayOfString.length;
    for (int j = 0; ; j++)
    {
      if (j >= i)
        return str1;
      String str2 = arrayOfString[j];
      if (str1.startsWith(str2))
        str1 = str1.substring(str2.length(), 1 + str2.length()).toLowerCase() + str1.substring(1 + str2.length());
    }
  }

  public static String getNormalizedName(Method paramMethod)
  {
    if (paramMethod == null)
      return null;
    return getNormalizedName(paramMethod.getName());
  }

  public static Method getSetterMethod(Class<?> paramClass, String paramString)
  {
    String str = "set" + getDenormalizedName(paramString);
    Object localObject = paramClass;
    if (localObject == null);
    while (true)
      while (true)
      {
        Method localMethod = null;
        label29: return localMethod;
        try
        {
          Method[] arrayOfMethod = paramClass.getMethods();
          int i = arrayOfMethod.length;
          for (int j = 0; ; j++)
          {
            if (j >= i)
            {
              localObject = ((Class)localObject).getSuperclass();
              break;
            }
            localMethod = arrayOfMethod[j];
            if (str.equals(localMethod.getName()))
            {
              int k = localMethod.getParameterTypes().length;
              if (k == 1)
                break label29;
            }
          }
        }
        catch (SecurityException localSecurityException)
        {
        }
      }
  }

  public static Method getSetterMethod(Class<?> paramClass1, String paramString, Class<?> paramClass2)
  {
    String str = getDenormalizedName(paramString);
    try
    {
      Method localMethod = paramClass1.getMethod("set" + str, new Class[] { paramClass2 });
      return localMethod;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      return null;
    }
    catch (SecurityException localSecurityException)
    {
    }
    return null;
  }

  public static Method getSetterMethod(Method paramMethod)
  {
    int i = 0;
    String str1 = getNormalizedName(paramMethod);
    Class localClass1 = paramMethod.getReturnType();
    Class localClass2 = paramMethod.getDeclaringClass();
    String str2 = getDenormalizedName(str1);
    Object localObject = null;
    String[] arrayOfString = PREFIXES;
    int j = arrayOfString.length;
    while (true)
    {
      if (i >= j)
        label43: return localObject;
      String str3 = arrayOfString[i];
      try
      {
        Method localMethod = localClass2.getMethod(str3 + str2, new Class[] { localClass1 });
        localObject = localMethod;
        label91: if (localObject != null)
          break label43;
        i++;
      }
      catch (NoSuchMethodException localNoSuchMethodException)
      {
        break label91;
      }
      catch (SecurityException localSecurityException)
      {
        break label91;
      }
    }
  }

  public static boolean isGetter(Method paramMethod)
  {
    String str = paramMethod.getName();
    if (str.startsWith("get"));
    while (str.startsWith("is"))
      return true;
    return false;
  }

  public static boolean isSetter(Method paramMethod)
  {
    return paramMethod.getName().startsWith("set");
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.h2.util.lang.reflect.ReflectUtils
 * JD-Core Version:    0.6.2
 */